<?php

namespace App\Console\Commands;

use App\Admin\Models\Financial\FinancialLiabilities;
use App\Store\Models\Financial\Statements\Liabilities;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

class CheckoutLiabilitiesYear extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:CheckoutLiabilitiesYear';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '结算年负债数据';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        Log::info('结算年负债数据开始');
        $this->checkoutliabilitiesyear();
        Log::info('结算年负债数据结束');
        return 0;
    }

    public function checkoutliabilitiesyear()
    {
        $where = [
            'year' => date('Y') - 1,
            'month' => 12,
            'day' => 31,
        ];
        Liabilities::where($where)->update(['is_end' => 2]);
        FinancialLiabilities::where($where)->update(['is_end' => 2]);
    }
}
